﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PerCiGal.BPC
{
	public class BPCMovie : IBPCMovie
	{
		/// <summary>
		/// Insert new movie in collection
		/// </summary>
		/// <param name="collectionInfo"></param>
		/// <param name="movie"></param>
		/// <returns></returns>
		public int MovieDetailsInsert(Types.COLLECTION_INFO collectionInfo, Types.MOVIE_DETAILS movie)
		{
			try
			{
				var dalMovie = new DAL.DALMovie(collectionInfo);

				movie.DT_CREATION = DateTime.UtcNow;
				movie.DT_LAST_MODIFIED = DateTime.UtcNow;

				return dalMovie.MovieDetailsInsert(movie);
			}
			catch (Exception exc)
			{
				throw exc;
			}
		}

		/// <summary>
		/// Update data of movie
		/// </summary>
		/// <param name="collectionInfo"></param>
		/// <param name="movie"></param>
		public void MovieDetailsUpdate(Types.COLLECTION_INFO collectionInfo, Types.MOVIE_DETAILS movie)
		{
			try
			{
				var dalMovie = new DAL.DALMovie(collectionInfo);

				movie.DT_LAST_MODIFIED = DateTime.UtcNow;

				dalMovie.MovieDetailsUpdate(movie);
			}
			catch (Exception exc)
			{
				throw exc;
			}
		}

		/// <summary>
		/// Remove movie from collection
		/// </summary>
		/// <param name="collectionInfo"></param>
		/// <param name="codMovie"></param>
		public void MovieDetailsDeleteByCodMovie(Types.COLLECTION_INFO collectionInfo, int codMovie)
		{
			try
			{
				var dalMovie = new DAL.DALMovie(collectionInfo);

				dalMovie.MovieDetailsDeleteByCodMovie(codMovie);
			}
			catch (Exception exc)
			{
				throw exc;
			}
		}

		/// <summary>
		/// Get movie details
		/// </summary>
		/// <param name="collectionInfo"></param>
		/// <param name="codMovie"></param>
		/// <returns></returns>
		public Types.MOVIE_DETAILS MovieDetailsSelectByCodMovie(Types.COLLECTION_INFO collectionInfo, int codMovie)
		{
			try
			{
				var dalMovie = new DAL.DALMovie(collectionInfo);

				return dalMovie.MovieDetailsSelectByCodMovie(codMovie);
			}
			catch (Exception exc)
			{
				throw exc;
			}
		}
	}
}
